﻿<!DOCTYPE html>
<html lang="en-us">
<head>
    <meta charset="utf-8">
    <title>数据提取记录列表
    </title>
    <meta name="description" content="">
    <meta name="author" content="">

    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <!-- #CSS Links -->
    <!-- Basic Styles -->
    <link rel="stylesheet" type="text/css" media="screen" href="css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" media="screen" href="css/font-awesome.css">

    <!-- SmartAdmin Styles : Caution! DO NOT change the order -->
    <link rel="stylesheet" type="text/css" media="screen" href="css/smartadmin-production-plugins.css">
    <link rel="stylesheet" type="text/css" media="screen" href="css/smartadmin-production.css">
    <link rel="stylesheet" type="text/css" media="screen" href="css/smartadmin-skins.css">

    <!-- SmartAdmin RTL Support -->
    <link rel="stylesheet" type="text/css" media="screen" href="css/smartadmin-rtl.css">

    <!-- Demo purpose only: goes with demo.js, you can delete this css when designing your own WebApp -->
    <link rel="stylesheet" type="text/css" media="screen" href="css/demo.css">

    <!-- #FAVICONS -->
    <link rel="shortcut icon" href="img/favicon/favicon.ico" type="image/x-icon">
    <link rel="icon" href="img/favicon/favicon.ico" type="image/x-icon">

    <!-- #GOOGLE FONT -->
    <link rel="stylesheet" href="css/open-sans.css" type="text/css">

    <!-- #APP SCREEN / ICONS -->
    <link rel="apple-touch-icon" href="img/splash/sptouch-icon-iphone.png">
    <link rel="apple-touch-icon" sizes="76x76" href="img/splash/touch-icon-ipad.png">
    <link rel="apple-touch-icon" sizes="120x120" href="img/splash/touch-icon-iphone-retina.png">
    <link rel="apple-touch-icon" sizes="152x152" href="img/splash/touch-icon-ipad-retina.png">

    <!-- iOS web-app metas : hides Safari UI Components and Changes Status Bar Appearance -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">

    <!-- Startup image for web apps -->
    <link rel="apple-touch-startup-image" href="img/splash/ipad-landscape.png"
        media="screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape)">
    <link rel="apple-touch-startup-image" href="img/splash/ipad-portrait.png"
        media="screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait)">
    <link rel="apple-touch-startup-image" href="img/splash/iphone.png" media="screen and (max-device-width: 320px)">
    <link href="appcss/Common.css" rel="stylesheet" />
</head>
<body class="desktop-detected minified">

    <!-- #MAIN PANEL -->
    <div id="main" role="main">

        <!-- RIBBON -->
        <div id="ribbon">


            <span class="ribbon-button-alignment">
                <span class="btn btn-ribbon"><i class="fa fa-home"></i></span>
            </span>

            <!-- breadcrumb -->
            <ol class="breadcrumb">
                <li><a href="DataExtractionRecordsOne.html">数据提取记录管理</a></li>
                <li>数据提取记录列表</li>
            </ol>
            <!-- end breadcrumb -->

        </div>
        <!-- END RIBBON -->


        <!-- MAIN CONTENT -->
        <div id="content">
            <div class="row hidden">
                <div class="col-xs-12 col-sm-7 col-md-7 col-lg-4">
                    <h1 class="page-title txt-color-blueDark">
                        <i class="fa fa-edit fa-fw "></i>
                        主页
            <span>> 
				数据提取记录列表
            </span>
                    </h1>
                </div>

            </div>

            <!-- widget grid -->
            <section id="widget-grid" class="">

                <!-- row -->
                <div class="row">

                    <!-- NEW WIDGET START -->


                    <!-- NEW WIDGET START -->
                    <article class="col-sm-12 col-md-12 ">

                        <!-- Widget ID (each widget will need unique ID)-->
                        <div class="jarviswidget">

                            <!-- widget div-->
                            <div>
                                <!-- widget content -->
                                <div class="widget-body no-padding">

                                    <!-- Success states for elements -->
                                    <form action="#" class="smart-form">
                                        <fieldset>
                                            <section>
                                                <label class="label">外部程序</label>
                                                <label class="input">
                                                    <input type="text" disabled="disabled" value="program" id="AppName" />
                                                </label>
                                            </section>
                                            <section>
                                                <label class="label">时间</label>
                                                <label class="input">
                                                    <input type="text" disabled="disabled" value="2014-1-1" id="Time" />
                                                </label>
                                            </section>
                                            <section>
                                                <label class="label">提供：<span id="ProvideData"></span>， 被提取：<span id="ExtractData"></span></label>
                                            </section>
                                            <!--                                            <section>

                                                <a class="btn btn-primary" onclick="Reexecute()" style="padding: 6px 12px !important;"
                                                    href="javascript:void(0);">重新抽取</a>
                                            </section>-->
                                            <section>
                                                <table class="table table-hover table-bordered " id="Table-Data">
                                                    <thead>
                                                        <tr>
                                                            <th>ID</th>
                                                            <th>BatchID</th>
                                                            <th>抽取时间</th>
                                                            <th>Reason</th>
                                                            <th>操作</th>
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                                    </tbody>
                                                </table>
                                            </section>
                                        </fieldset>
                                        <footer>
                                            <button type="button" class="btn btn-primary" onclick="Reexecute()">
                                                重新抽取
                                            </button>
                                            <button type="button" class="btn btn-default" onclick="window.history.back();">
                                                返回
                                            </button>

                                        </footer>
                                    </form>
                                    <!--/ Success states for elements -->
                                </div>
                                <!-- end widget content -->
                            </div>
                            <!-- end widget div -->
                        </div>
                        <!-- end widget -->
                    </article>
                </div>

                <!-- end row -->

            </section>
        </div>
        <!-- END MAIN CONTENT -->
    </div>


    <!--================================================== -->

    <!-- PACE LOADER - turn this on if you want ajax loading to show (caution: uses lots of memory on iDevices)
<script data-pace-options='{ "restartOnRequestAfter": true }' src="js/plugin/pace/pace.min.js"></script>-->


    <!-- #PLUGINS -->
    <!-- Link to Google CDN's jQuery + jQueryUI; fall back to local -->


    <script src="js/libs/jquery-2.1.1.min.js"></script>
    <script src="js/libs/jquery-ui-1.10.3.min.js"></script>
    <!-- BOOTSTRAP JS -->
    <script src="js/bootstrap/bootstrap.min.js"></script>

    <!-- IMPORTANT: APP CONFIG -->
    <script src="js/app.config.js"></script>


    <!-- CUSTOM NOTIFICATION -->
    <script src="js/notification/SmartNotification.min.js"></script>

    <!-- JARVIS WIDGETS -->
    <script src="js/smartwidgets/jarvis.widget.min.js"></script>


    <!-- SPARKLINES -->
    <script src="js/plugin/sparkline/jquery.sparkline.min.js"></script>

    <!-- JQUERY MASKED INPUT -->
    <script src="js/plugin/masked-input/jquery.maskedinput.min.js"></script>


    <!-- JQUERY UI + Bootstrap Slider -->
    <script src="js/plugin/bootstrap-slider/bootstrap-slider.min.js"></script>
    <script src="js/plugin/datatables/jquery.dataTables.min.js"></script>
    <script src="js/plugin/datatables/dataTables.colVis.min.js"></script>
    <script src="js/plugin/datatables/dataTables.tableTools.min.js"></script>
    <script src="js/plugin/datatables/dataTables.bootstrap.min.js"></script>
    <script src="js/plugin/datatable-responsive/datatables.responsive.min.js"></script>
    <script src="appjs/Common.js"></script>
    <script src="appjs/Helper.js"></script>
    <script src="js/app.min.js"></script>
    <script src="js/plugin/My97DatePicker/WdatePicker.js"></script>
    <script>
        var draw = 0;
        var batchId;
        var data = unescape(GetQueryString("data"));
        var AppId;
        var RecordId;
        var ServiceType;
        var Service;
        var SourceType;
        var Source;
        var datacolumns = new Array();
        var page = 1;
        var noAjaxForOneData;
        $(function () {
            if (data != "") {
                var jsonobj = JSON.parse(data);
                $("#AppName").val(jsonobj.AppName);
                $("#Time").val(jsonobj.CreatedTime);
                $("#ProvideData").html(jsonobj.DataCount);
                $("#ExtractData").html(jsonobj.ExtractedCount);
                AppId = jsonobj.AppId;
                RecordId = jsonobj.Id;
                ServiceType = jsonobj.DataServiceType;
                Service = jsonobj.DataService;
                SourceType = jsonobj.DataSourceType;
                Source = jsonobj.DataSource;
                batchId = jsonobj.BatchId;
                intData();
                //GetReexecuteBatch();
            } else {
                alert("参数不正确");
            }

        });
        var getDataSourceDetails = function () {
            $.ajax({
                url: apiUrl,
                data: {
                    "sys:sno": "ETL",
                    "sys:act": "GetDataSource",
                    "DataServiceId": ServiceId,
                    "DataSourceId": dataSourceId
                },
                dataType: "json",
                success: function (data) {
                    if (data.IsSccuess) {
                        var str = "";
                        $("#SourceName").val(data.Data.Name);//名称
                        AppadData(data.Data.Columns);//组装数据并并填充表格
                    } else {
                        if (IsLogined(data.ErrorCode)) {
                            alert(data.Message);
                        }
                    }
                },
                beforeSend: function () {
                    // $("btn_login").html("登录中...");
                }
            });
        }
        //初始化数据
        var intData = function () {
            $.ajax({
                url: apiUrl,
                dataType: "json",
                data: {
                    "sys:sno": "AppExtract",
                    "sys:act": "GetRejectedDataList",
                    "AppId": AppId,
                    "RecordId": RecordId,
                    "ServiceType": ServiceType,
                    "Service": Service,
                    "SourceType": SourceType,
                    "Source": Source,
                    "Page": 0
                },
                success: function (result) {
                    noAjaxForOneData = result;
                    if (result.IsSccuess) {
                        var trs = "<tr>";
                        for (var i = 0; i < result.Data.Columns.length; i++) {
                            var $this = result.Data.Columns[i];
                            if ($this.indexOf("_") != -1) {
                                continue;
                            } else {
                                trs += ("<th>" + $this + "</th>");
                                datacolumns.push({ "data": $this });
                            }
                        }
                        datacolumns.push({ data: "option" });
                        trs += ("<th>操作</th>");
                        trs += "</tr>";
                        $("#Table-Data thead").html(trs);
                        initializationDataTableForMine();
                    } else {
                        if (IsLogined(result.ErrorCode)) {
                            alert("失败（" + "错误代码：" + result.ErrorCode + "，错误信息：" + result.Message + ")");
                        }
                    }
                }
            });
        }
        var initializationDataTableForMine = function () {
            //初始化表格
            try {
                $('#Table-Data').dataTable({
                    "autoWidth": true,
                    "oLanguage": dataTableConfig,
                    "bLengthChange": false,
                    ordering: false,
                    bProcessing: true,
                    bStateSave: true,
                    serverSide: true,
                    searching: false,
                    aLengthMenu: [25],
                    "ajax": {
                        url: apiUrl,
                        "dataSrc": function (json) {
                            if (json.IsSccuess) {
                                var newjson = new Array();
                                for (var i = 0; i < json.Data.Items.length; i++) {
                                    var obj = new Object();
                                    var batchId = "";
                                    var dataId = "";
                                    for (var j = 0; j < json.Data.Columns.length; j++) {
                                        var $this = json.Data.Columns[j];
                                        if ($this.indexOf("_") != -1) {
                                            //var editstr = "<a href=\"DataExtractionRecordBatch.html?batchId=" + json.Data.Items[i].Values[j] + "&dataId=" + json.Data.Items[i].Values[j] + "&ServiceType=" + ServiceType + "&Source=" + Source + "\"><i class=\"fa fa-eye\"></i>查看</a>";
                                            //obj["option"] = editstr;
                                            if ($this == "_BatchId") {
                                                batchId = json.Data.Items[i].Values[j];
                                            } else if ($this == "_Id") {
                                                dataId = json.Data.Items[i].Values[j];
                                            }

                                        } else {
                                            obj[$this] = json.Data.Items[i].Values[j];
                                        }
                                    }
                                    var editstr = "<a href=\"DataExtractionRecordBatch.html?batchId=" + batchId + "&dataId=" + dataId + "&ServiceType=" + ServiceType + "&Source=" + Source + "\"><i class=\"fa fa-eye\"></i>查看</a>";
                                    obj["option"] = editstr;
                                    newjson.push(obj);

                                }
                                return newjson;
                            } else {
                                if (IsLogined(json.ErrorCode)) {
                                    alert("错误代码：" + json.ErrorCode + "，错误信息：" + json.Message);
                                }
                            }
                            return [];
                        },
                        "data": function (d) {
                            draw = d.draw;
                            if (page == 1) {
                                page++;
                                return $.extend({},
                               { "sys:sno": "AppExtract" },
                               { "sys:act": "GetRejectedDataList" },
                               { "AppId": AppId },
                               { "RecordId": RecordId },
                               { "ServiceType": ServiceType },
                               { "Source": Source },
                               { "Page": parseInt(d.start / d.length) }, { "noAjaxForOne": true });
                            } else {
                                return $.extend({},
                               { "sys:sno": "AppExtract" },
                               { "sys:act": "GetRejectedDataList" },
                               { "AppId": AppId },
                               { "RecordId": RecordId },
                               { "ServiceType": ServiceType },
                               { "Source": Source },
                               { "Page": parseInt(d.start / d.length) });
                            }

                        }
                    },
                    columns: datacolumns
                });
            } catch (e) {
                console.log(e);
            }
        }
        //var GetReexecuteBatch = function () {
        //    $.ajax({
        //        url: apiUrl,
        //        dataType: "json",
        //        data: {
        //            "sys:sno": "AppExtract",
        //            "sys:act": "GetReexecuteBatch",
        //            "AppId": AppId,
        //            "RecordId": RecordId,
        //            "ServiceType": ServiceType,
        //            "Source": Source
        //        },
        //        success: function (result) {
        //            if (result.IsSccuess) {

        //            } else {
        //                if (IsLogined(result.ErrorCode)) {
        //                    alert("失败（" + "错误代码：" + result.ErrorCode + "，错误信息：" + result.Message + ")");
        //                }
        //            }
        //        }
        //    });
        //}
        var Reexecute = function () {
            window.location.href = "DataExtractionReexecute.html?AppId=" + AppId + "&RecordId=" + RecordId + "&ServiceType=" + ServiceType + "&Source=" + Source;
        }
    </script>

</body>
</html>
